package com.xthh._struct;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Rect;


import com.xthh._enum.HH_EnumColorType;
import com.xthh._enum.HH_EnumLayerType;
import com.xthh._enum.HH_EnumTextAlgin;

import java.io.Serializable;

public class HH_T_LayerInfo implements Cloneable, Serializable {
    private int x;
    private int y;
    private int w;
    private int h;
    private String fontName="DEFAULT";
    private int fontSize=8;
    private int font_r;
    private int font_g;
    private int font_b;
    private int bkg_r;
    private int bkg_g;
    private int bkg_b;
    private String layerName;// 图层名称
    private boolean isBold;// 是否粗体
    private HH_EnumTextAlgin textAlgin = HH_EnumTextAlgin.LEFT;//0left,1center,2right
    private String text="";// 文本内容
    private HH_EnumLayerType layerAttr = HH_EnumLayerType.TYPE_TXT; // 图层属性，文本、图片、二维码或条码
    private String picPath;// 图片路径
    private boolean picAttr;// 0正常图片，1抖点(抖点参数默认的)
    private Bitmap bitmapPicLayer;// 图片图层的
    private int picSrcWidth = 0;  // 这两个，在选择图后就不会改变了
    private int picSrcHeight = 0;// 文件的宽和高
    private int rotate = 0;// 旋转参数，0不变，1顺时针90度，2旋转180度，3顺时针旋270度
    private String modelID;// db 使用

    public String getModelID() {
        return modelID;
    }

    public void setModelID(String modelID) {
        this.modelID = modelID;
    }

    public int getPicSrcWidth() {
        return picSrcWidth;
    }

    public void setPicSrcSize(int w, int h){
        this.picSrcWidth = w;
        this.picSrcHeight = h;
    }

    public void setPicSrcWidth(int picSrcWidth) {
        this.picSrcWidth = picSrcWidth;
    }

    public int getPicSrcHeight() {
        return picSrcHeight;
    }

    public void setPicSrcHeight(int picSrcHeight) {
        this.picSrcHeight = picSrcHeight;
    }


    public Bitmap getBitmapPicLayer() {
        return bitmapPicLayer;
    }

    public void setBitmapPicLayer(Bitmap bitmapPicLayer) {
        this.bitmapPicLayer = bitmapPicLayer;
    }

    public HH_EnumLayerType getLayerAttr() {
        return layerAttr;
    }

    public void setLayerAttr(HH_EnumLayerType layerAttr) {
        this.layerAttr = layerAttr;
    }

    public String getPicPath() {
        return picPath;
    }

    public void setPicPath(String picPath) {
        this.picPath = picPath;
    }

    public boolean isPicAttr() {
        return picAttr;
    }

    public void setPicAttr(boolean picAttr) {
        this.picAttr = picAttr;
    }

    public boolean isBold() {
        return isBold;
    }
    public void setBold(boolean bold) {
        isBold = bold;
    }
    public String getLayerName() {
        return layerName;
    }
    public void setLayerName(String layerName) {
        this.layerName = layerName;
    }
    public int getBkg_r() {
        return bkg_r;
    }

    public int getBkgColor(){
        return Color.rgb(bkg_r, bkg_g, bkg_b);
    }

    public void setBkg_r(int bkg_r) {
        this.bkg_r = bkg_r;
    }
    public int getBkg_g() {
        return bkg_g;
    }
    public void setBkg_g(int bkg_g) {
        this.bkg_g = bkg_g;
    }
    public int getBkg_b() {
        return bkg_b;
    }
    public void setBkg_b(int bkg_b) {
        this.bkg_b = bkg_b;
    }



    public HH_T_LayerInfo clone()  {
        try {
            return (HH_T_LayerInfo) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();

        }
        return null;
    }

    public HH_T_LayerInfo() {

    }

    public HH_T_LayerInfo(int x, int y, int w, int h) {
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
    }


    public HH_T_LayerInfo(int x, int y, int w, int h,
                          HH_EnumColorType fontColor,
                          HH_EnumTextAlgin textAlgin,
                          String layerName, String text, boolean isBold) {
        this.layerAttr = HH_EnumLayerType.TYPE_TXT;
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
        this.fontName = "DEFAULT";
        this.fontSize = h;
        this.isBold = isBold;
        switch (fontColor){

            case WHITE:{
                this.font_r = 255;
                this.font_g = 255;
                this.font_b = 255;
                break;
            }
            case BLACK:{
                this.font_r = 0;
                this.font_g = 0;
                this.font_b = 0;
                break;
            }
            case RED:{
                this.font_r = 255;
                this.font_g = 0;
                this.font_b = 0;
                break;
            }

            case GREEN:{
                this.font_r = 0;
                this.font_g = 255;
                this.font_b = 0;
                break;
            }

            case BLUE:{
                this.font_r = 0;
                this.font_g = 0;
                this.font_b = 255;
                break;
            }

            case YELLOW:{
                this.font_r = 255;
                this.font_g = 255;
                this.font_b = 0;
                break;
            }
            case ORANGE:{
                this.font_r = 255;
                this.font_g = 128;
                this.font_b = 0;
                break;
            }
            default:{
                this.font_r = 0;
                this.font_g = 0;
                this.font_b = 0;
            }

        }


        this.bkg_r = -1;
        this.bkg_g = -1;
        this.bkg_b = -1;
        this.textAlgin = textAlgin;
        this.text = text;
        this.layerName = layerName;
    }

    public HH_T_LayerInfo(int x, int y, int w, int h,
                          HH_EnumColorType fontColor,
                          HH_EnumTextAlgin textAlgin,
                          String layerName, String text) {
        this.layerAttr = HH_EnumLayerType.TYPE_TXT;
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
        this.fontName = "DEFAULT";
        this.fontSize = h;

        switch (fontColor){

            case WHITE:{
                this.font_r = 255;
                this.font_g = 255;
                this.font_b = 255;
                break;
            }
            case BLACK:{
                this.font_r = 0;
                this.font_g = 0;
                this.font_b = 0;
                break;
            }
            case RED:{
                this.font_r = 255;
                this.font_g = 0;
                this.font_b = 0;
                break;
            }

            case GREEN:{
                this.font_r = 0;
                this.font_g = 255;
                this.font_b = 0;
                break;
            }

            case BLUE:{
                this.font_r = 0;
                this.font_g = 0;
                this.font_b = 255;
                break;
            }

            case YELLOW:{
                this.font_r = 255;
                this.font_g = 255;
                this.font_b = 0;
                break;
            }
            case ORANGE:{
                this.font_r = 255;
                this.font_g = 128;
                this.font_b = 0;
                break;
            }
            default:{
                this.font_r = 0;
                this.font_g = 0;
                this.font_b = 0;
            }

        }


        this.bkg_r = -1;
        this.bkg_g = -1;
        this.bkg_b = -1;
        this.textAlgin = textAlgin;
        this.text = text;
        this.layerName = layerName;
    }


    public HH_T_LayerInfo(int x, int y, int w, int h, int fontSize, String fontName,
                          HH_EnumColorType fontColor,
                          HH_EnumTextAlgin textAlgin,
                          String layerName, String text) {

        this.layerAttr = HH_EnumLayerType.TYPE_TXT;

        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
        this.fontSize = fontSize;
        this.fontName = fontName;
        switch (fontColor){

            case WHITE:{
                this.font_r = 255;
                this.font_g = 255;
                this.font_b = 255;
                break;
            }
            case BLACK:{
                this.font_r = 0;
                this.font_g = 0;
                this.font_b = 0;
                break;
            }
            case RED:{
                this.font_r = 255;
                this.font_g = 0;
                this.font_b = 0;
                break;
            }

            case GREEN:{
                this.font_r = 0;
                this.font_g = 255;
                this.font_b = 0;
                break;
            }

            case BLUE:{
                this.font_r = 0;
                this.font_g = 0;
                this.font_b = 255;
                break;
            }

            case YELLOW:{
                this.font_r = 255;
                this.font_g = 255;
                this.font_b = 0;
                break;
            }
            case ORANGE:{
                this.font_r = 255;
                this.font_g = 128;
                this.font_b = 0;
                break;
            }
            default:{
                this.font_r = 0;
                this.font_g = 0;
                this.font_b = 0;
            }

        }


        this.bkg_r = -1;
        this.bkg_g = -1;
        this.bkg_b = -1;
        this.textAlgin = textAlgin;
        this.text = text;
        this.layerName = layerName;
    }

    public HH_T_LayerInfo(int x, int y, int w, int h,
                          String fontName, int fontSize,
                          int font_r, int font_g, int font_b, int bkg_r, int bkg_g, int bkg_b,
                          HH_EnumTextAlgin textAlgin, String text,
                          String layerName) {
        this.layerAttr = HH_EnumLayerType.TYPE_TXT;
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
        this.fontName = fontName;
        this.fontSize = fontSize;
        this.font_r = font_r;
        this.font_g = font_g;
        this.font_b = font_b;

        this.bkg_r = bkg_r;
        this.bkg_g = bkg_g;
        this.bkg_b = bkg_b;

        this.textAlgin = textAlgin;
        this.text = text;
        this.layerName = layerName;
    }


    public HH_T_LayerInfo(int x, int y, int w, int h,
                          String fontName, int fontSize,
                          int font_r, int font_g, int font_b, int bkg_r, int bkg_g, int bkg_b,
                          HH_EnumTextAlgin textAlgin, String text) {
        this.layerAttr = HH_EnumLayerType.TYPE_TXT;
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
        this.fontName = fontName;
        this.fontSize = fontSize;
        this.font_r = font_r;
        this.font_g = font_g;
        this.font_b = font_b;

        this.bkg_r = bkg_r;
        this.bkg_g = bkg_g;
        this.bkg_b = bkg_b;

        this.textAlgin = textAlgin;
        this.text = text;
    }
    public void setXYWH(int x, int y, int w, int h){
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
    }
    public void setXY(int x, int y){
        this.x = x;
        this.y = y;
    }

    public String getText() {
        return text;
    }
    public void setText(String text) {
        this.text = text;
    }
    public int getW() {
        return w;
    }
    public void setW(int w) {
        this.w = w;
    }
    public int getH() {
        return h;
    }
    public void setH(int h) {
        this.h = h;
    }
    public HH_EnumTextAlgin getTextAlgin() {
        return textAlgin;
    }
    public String getTextAlgins(){
        if (textAlgin == HH_EnumTextAlgin.LEFT)
            return "left";
        else if (textAlgin == HH_EnumTextAlgin.CENTER)
            return "center";
        else
            return "right";
    }
    public void setTextAlgin(HH_EnumTextAlgin textAlgin) {
        this.textAlgin = textAlgin;
    }
    public int getX() {
        return x;
    }
    public void setX(int x) {
        this.x = x;
    }
    public int getY() {
        return y;
    }
    public void setY(int y) {
        this.y = y;
    }
    public String getFontName() {
        return fontName;
    }
    public void setFontName(String fontName) {
        this.fontName = fontName;
    }
    public int getFontSize() {
        return fontSize;
    }
    public void setFontSize(int fontSize) {
        this.fontSize = fontSize;
    }
    public int getFont_r() {
        return font_r;
    }

    public int getFontColor(){
        return Color.rgb(font_r, font_g, font_b);
    }

    public void setFont_r(int font_r) {
        this.font_r = font_r;
    }
    public int getFont_g() {
        return font_g;
    }
    public void setFont_g(int font_g) {
        this.font_g = font_g;
    }
    public int getFont_b() {
        return font_b;
    }
    public void setFont_b(int font_b) {
        this.font_b = font_b;
    }
    public void setRGB(int r, int g, int b){
        this.font_r = r;
        this.font_g = g;
        this.font_b = b;
    }
    public void setRGB(HH_T_RGB rgb){
        this.font_r = rgb.getR();
        this.font_g = rgb.getG();
        this.font_b = rgb.getB();
    }

    public void setBkgRGB(int r, int g, int b){
       this.bkg_r  = r;
       this.bkg_g  = g;
       this.bkg_b  = b;
    }
    public void setBkgRGB(HH_T_RGB rgb){
        this.bkg_r = rgb.getR();
        this.bkg_g = rgb.getG();
        this.bkg_b = rgb.getB();
    }
    public HH_T_RGB getBkgRGB(){
        return new HH_T_RGB(this.bkg_r, this.bkg_g, this.bkg_b);
    }

    public String getRGBss(){
        if (font_r == 255 && font_g == 255 && font_b == 255)
            return "white";
        else if (font_r == 0 && font_g == 0 && font_b == 0)
            return "black";
        else if (font_r == 255 && font_g == 0 && font_b == 0)
            return "red";
        else if (font_r == 0 && font_g == 255 && font_b == 0)
            return "green";
        else if (font_r == 0 && font_g == 0 && font_b == 255)
            return "blue";
        else if (font_r == 255 && font_g == 255 && font_b == 0)
            return "yellow";
        else if (font_r == 255 && font_g == 127 && font_b == 0)
            return "orange";
        else
            return "black";
    }

    public String getBkgRGBss(){
        if (bkg_r == 255 && bkg_g == 255 && bkg_b == 255)
            return "white";
        else if (bkg_r == 0 && bkg_g == 0 && bkg_b == 0)
            return "black";
        else if (bkg_r == 255 && bkg_g == 0 && bkg_b == 0)
            return "red";
        else if (bkg_r == 0 && bkg_g == 255 && bkg_b == 0)
            return "green";
        else if (bkg_r == 0 && bkg_g == 0 && bkg_b == 255)
            return "blue";
        else if (bkg_r == 255 && bkg_g == 255 && bkg_b == 0)
            return "yellow";
        else if (bkg_r == 255 && bkg_g == 127 && bkg_b == 0)
            return "orange";
        else if (bkg_r == -1 && bkg_g == -1 && bkg_b == -1)
            return "transparent"; // 透明
        else
            return "black";
    }

    public Rect getRectBtnClose(){
        return new Rect(x - 20, y - 20, x + 20, y + 20);
    }

    public Rect getRectBtnRotate(){
        return new Rect(x + w / 2 - 20, y + h - 20, x + w / 2 + 20, y + h + 20);
    }

    public Rect getRectBtnCopyWidget(){
        return new Rect(x + w - 20, y - 20, x + w + 20, y + 20);
    }


    public int getRotate() {
        return rotate;
    }

    public void setRotate(int rotate) {
        this.rotate = rotate;
    }
}
